package com.fuxue.service.impl;

import com.fuxue.mapper.RanklistMapper;
import com.fuxue.service.RanklistService;
import com.fuxue.vo.RankListVO;
import com.fuxue.vo.RankVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class RanklistServiceImpl implements RanklistService {
    @Autowired
    RanklistMapper ranklistMapper;

    @Override
    public RankVO getRand(Integer id) {
        List<RankListVO>list = ranklistMapper.getRank();
        RankVO rankVO = new RankVO();
        for (RankListVO rankListVO : list) {
            if(rankListVO.getServerId() == id){
            rankVO.setServerId(rankListVO.getServerId());
            rankVO.setServerName(rankListVO.getServerName());
            rankVO.setPoint(rankListVO.getPoint());
            rankVO.setNum(rankListVO.getNum());

           }
        }
        rankVO.setTime(LocalDateTime.now());
        return rankVO;
    }

    @Override
    public List<RankListVO> getRank() {
        List<RankListVO>list = ranklistMapper.getRank();
        return list;
    }
}
